//
//  Bundle+Additions.swift
//  Kingfisher
//
//  Created by Sariel Chen on 2019/11/4.
//

import Foundation

extension Bundle {
    public static func getBundle(bundleName: String) -> Bundle? {
        if let path = Bundle.init(for: Bundle.self).path(forResource: bundleName, ofType: "bundle", inDirectory: nil) {
            if let bundle = Bundle.init(path: path) {
                return bundle
            }
        }
        return nil
    }
    
    public static func getImage(bundleName: String, imageName: String) -> UIImage? {
        if let bundle = Bundle.getBundle(bundleName: bundleName), let image = UIImage(named: imageName, in: bundle, compatibleWith: nil) {
            return image
        }
        return UIImage(named: imageName)
    }
}
